#pragma once
#include "vbackgroundworker.h"
#ifdef UNDER_CE    // There is no player support under win32
#include "player/Player.h"


#pragma comment(lib, "StreamDll.lib")

class VPlayer :
    public VBackgroundWorker
{
    typedef enum
    {
        NOEVENT,
        // STOP,
        PLAY,
        PAUSE,
        NEXT,
        SILENT,
        NORMAL,
        EXIT
    } event_t;

    typedef struct
    {
        unsigned int id;
        std::string songname;
        std::string path;
    } song_t;

    typedef std::vector<song_t> songlist_t;
protected:
    VPlayer(void);

public:
    virtual ~VPlayer(void);

public:
    void eventControl(event_t event);
    void setEventArgument(const std::string& arg);
    void addSong(const std::string& songname, const std::string& path);

protected:  // internal interface
    void nextsong();
    void setSilentMode();
    void setNormalMode();
    void play();
    void pause();
    void updateUi();

protected:
    static VPlayer* s_pThis;
    static event_t s_event;
public:
    static VPlayer* createVPlayer();
    static bool getEvent(event_t* event);

public: // callback functions
    static int SDLCALL vplayerController(void*);
    static void playDone(int);


public:
    static bool CALLBACK cbPlayOrPause(int, int, VButton*);
    static bool CALLBACK cbNext(int, int, VButton*);
    static bool CALLBACK cbSilentOrNormal(int, int, VButton*);

protected:
    songlist_t* _songlist;
    int _currentSong;
    bool _playStatus;
    bool _silentStatus;
    std::string _eventargument;
};

#endif  // UNDER_CE